//
//  M1WsSexView.m
//  NewMarryU
//
//  Created by apple on 2018/7/13.
//  Copyright © 2018年 Cedar. All rights reserved.
//

#import "M1WsSexView.h"

@implementation M1WsSexView

-(void)m1_btnClick:(UIButton *)sender{
    [_m1_selectBtn setTitleColor:[UIColor m1_colorHex:0x999999] forState:0];
    [_m1_selectBtn setImage:[UIImage imageNamed:@"ws_sex_n"] forState:0];[sender setTitleColor:[UIColor m1_colorHex:0x333333] forState:0];
    [sender setImage:[UIImage imageNamed:@"ws_sex_s"] forState:0];
    _m1_selectBtn = sender;
    
    if (_selectSex) {
        _selectSex(sender.tag);
    }
}
-(instancetype)init{
    self = [super init];
    if (self) {
        UILabel * m1_titleLB = [[UILabel alloc]init];
        m1_titleLB.textColor = m1_line_color;
        m1_titleLB.font = m1_font(15);
        m1_titleLB.text = @"性别";
        [self addSubview:m1_titleLB];
        
        [m1_titleLB mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(24);
            make.centerY.equalTo(self);
        }];
        
        NSArray *array = @[@"男",@"女"];
        for (int i = 0; i<2; i++) {
            UIButton *m1_btn = [UIButton buttonWithType:UIButtonTypeCustom];
            [m1_btn setTitleColor:[UIColor m1_colorHex:0x999999] forState:0];
            m1_btn.titleLabel.font = m1_font(15);
            [m1_btn setTitle:array[i] forState:0];
            [m1_btn setImage:[UIImage imageNamed:@"ws_sex_n"] forState:0];
            m1_btn.tag = i;
            [m1_btn setImageEdgeInsets:UIEdgeInsetsMake(0, -10, 0, 10)];
            [m1_btn addTarget:self action:@selector(m1_btnClick:) forControlEvents:UIControlEventTouchUpInside];
            [self addSubview:m1_btn];
            [m1_btn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.offset(100+80*i);
                make.centerY.equalTo(self);
                make.height.equalTo(self);
                make.width.mas_offset(50);
            }];
            
        }
  
        
        UIView * m1_line = [[UIView alloc]init];
        m1_line.backgroundColor = m1_line_color;
        [self addSubview:m1_line];
        [m1_line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.bottom.right.offset(0);
            make.height.mas_offset(0.5);
        }];
    }
    return self;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
